<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">人才信息</div>
      </div>
      <div class="container">
        <!--  -->
        <div class="x-ico-month x-ico-month2">
          <el-date-picker v-model="cardsmonth" type="month" placeholder="选择月" @change="getmonthdata" format="yyyy 年 MM 月" value-format="yyyyMM" :editable="notkey"></el-date-picker>
        </div>
        <!--  -->
        <div class="x-ut-top">
            <div class="x-inc-num">系统参与门店：<span class="x-inc-g">{{personnum}}个</span></div>
            <div class="x-inc-num">本组参与店面：<span class="x-inc-g">{{personnum2}}个</span></div>
        </div>
        <el-tabs v-model="activeName" @tab-click="handleClick" stretch="true">
            <el-tab-pane label="系统信息" name="first">
                <div class="x-inc-num">系统当月在职：{{monthnum}}人</div>
                <el-table :data="tabledata" @cell-click="gotrainpro" show-summary>
                    <el-table-column type="index" label="序号" width="60" fixed></el-table-column>
                    <el-table-column label="职级名称" width="" prop="title" fixed> 
                      <template slot-scope="scope">
                        {{scope.row.title}}
                      </template>
                    </el-table-column>
                    <el-table-column label="年初在职" width="" prop="year_early">
                      <template slot-scope="scope">
                        {{scope.row.year_early}}
                      </template>
                    </el-table-column>
                    <el-table-column label="月初在职" width="" prop="month_early">
                      <template slot-scope="scope">
                        {{scope.row.month_early}}
                      </template>
                    </el-table-column>
                    <el-table-column label="本月增减/率" width="" prop="month_num">
                      <template slot-scope="scope">
                        {{scope.row.month_num}}/{{scope.row.month_rate}}%
                      </template>
                    </el-table-column>
                    <el-table-column label="年累计增减/率" width="" prop="year_num">
                      <template slot-scope="scope">
                        {{scope.row.year_num}}/{{scope.row.year_rate}}%
                      </template>
                    </el-table-column>
                    <el-table-column label="本月在职" width="" prop="month_incumbency">
                      <template slot-scope="scope">
                        {{scope.row.month_incumbency}}
                      </template>
                    </el-table-column>
                    <el-table-column label="占总数比" width="" prop="all_rate">
                      <template slot-scope="scope">
                        {{scope.row.all_rate}}%
                      </template>
                    </el-table-column>
                    <el-table-column label="查看" width="">
                      <template slot-scope="scope">
                        <el-button type="text" size="mini">查看</el-button>
                      </template>
                    </el-table-column>
                  </el-table>
            </el-tab-pane>
            <el-tab-pane label="本组信息" name="second">
                <div class="x-inc-num">本组当月在职：{{monthnum2}}人</div>
                <el-table :data="tabledatatwo" @cell-click="gotrainpro" show-summary>
                    <el-table-column type="index" label="序号" width="60" fixed></el-table-column>
                    <el-table-column label="职级名称" width="" fixed>
                        <template slot-scope="scope">
                          {{scope.row.title}}
                        </template>
                      </el-table-column>
                      <el-table-column label="年初在职" width="" prop="year_early">
                        <template slot-scope="scope">
                          {{scope.row.year_early}}
                        </template>
                      </el-table-column>
                      <el-table-column label="月初在职" width="" prop="month_early">
                        <template slot-scope="scope">
                          {{scope.row.month_early}}
                        </template>
                      </el-table-column>
                      <el-table-column label="本月增减/率" width="" prop="month_num">
                        <template slot-scope="scope">
                          {{scope.row.month_num}}/{{scope.row.month_rate}}%
                        </template>
                      </el-table-column>
                      <el-table-column label="年累计增减/率" width="" prop="year_num">
                        <template slot-scope="scope">
                            {{scope.row.year_num}}/{{scope.row.year_rate}}%
                        </template>
                      </el-table-column>
                      <el-table-column label="本月在职" width="" prop="month_incumbency">
                        <template slot-scope="scope">
                          {{scope.row.month_incumbency}}
                        </template>
                      </el-table-column>
                      <el-table-column label="占总数比" width="" prop="all_rate">
                        <template slot-scope="scope">
                          {{scope.row.all_rate}}%
                        </template>
                      </el-table-column>
                      <el-table-column label="查看" width="">
                        <template slot-scope="scope">
                          <el-button type="text" size="mini">查看</el-button>
                        </template>
                      </el-table-column>
                  </el-table>
            </el-tab-pane>
        </el-tabs>
		</div>

    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          tabsdata:[],
          curId:0,
          tabledata:[],
          tabledatatwo:[],
          cardsmonth:'',
          cardsmonthtoy:'',
          cardsmonthtom:'',
          tabsid:0,
          notkey:false,
          activeName: 'first',
          tabstype:1,
          personnum:'',
          personnum2:'',
          monthnum:0,
          monthnum2:0,

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        if(month<10){
          month = '' + 0 + month;
        }
        var toMonth = '' + year + month ;
        that.cardsmonth = toMonth;
        that.cardsmonthtoy = year;
        that.cardsmonthtom = month
        that.gettrainadmin('1')
      },
      methods: {
        //选项卡
        handleClick(tab, event) {
          console.log(tab, event);
          let id = event.target.getAttribute('id').split('-');
          let whitetab = id.join('').substring(3,9);
          let that = this;
          if(whitetab=='first'){
              that.tabstype=1;
              that.gettrainadmin('1')
          }else if(whitetab=='second'){
              that.tabstype = 2;
              that.gettrainadmin('2')
          }
        },
        //
        getmonthdata:function(val){
          var that = this;
          that.cardsmonth = val;
          that.cardsmonthtoy = that.cardsmonth.slice(0,4);
          that.cardsmonthtom = that.cardsmonth.slice(4,6);
          if (that.tabstype==1) {
            that.gettrainadmin('1')
          } else {
            that.gettrainadmin('2')
          }
          

        },
        //列
        gotrainpro:function(val){
          console.log(JSON.stringify(val));
          var that = this;
          api.openWin({
              name: 'z_userinfolist',
              url: './z_userinfolist.html',
              pageParam: {
                  id: val.id,
                  title:val.title,
                  date:that.cardsmonth,
                  type:that.tabstype
              }
          });
        },
        //列表
        gettrainadmin:function(type){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/comInfo',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                _gid:$api.getStorage('groupid'),
                date:that.cardsmonth,
                type:type
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.personnum = ret.data.sysCount;
                  that.personnum2 = ret.data.groupCount;
                  if(type==1){
                    that.tabledata = ret.data.list;
                    that.monthnum = ret.data.list.length;
                  }else if(type==2){
                    that.tabledatatwo = ret.data.list;
                    that.monthnum2 = ret.data.list.length;
                  }
                  
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}

	</script>
</body>
</html>
